import 'package:flutter/material.dart';
import 'package:ls_work/mvp/svp_progress.dart';
import 'package:ls_work/net/HttpUtil.dart';
import 'package:ls_work/net/net.dart';
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:ls_work/util/toast.dart';

class ElderCareDetailPage extends StatefulWidget {
  final int? id;
  ElderCareDetailPage({Key? key, this.id});
  @override
  _ElderCareDetailPageState createState() => _ElderCareDetailPageState();
}

class _ElderCareDetailPageState extends State<ElderCareDetailPage> {
  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      _fectData();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('整合性照护计划'),
        elevation: 0.5,
      ),
      body: SingleChildScrollView(),
    );
  }

  ///获取数据
  _fectData() {
    var map = {
      'id': widget.id,
    };
    SVProgressHUD page = SVProgressHUD(context);
    page.showProgress();
    HttpUtil.instance
        .getDio()
        .post(HttpApi.servicePlanElder, data: map)
        .then((r) {
      ///
      page.closeProgress();
      if (r.statusCode == 200) {
        Map<String, dynamic> map = json.decode(r.toString());

        if (map["code"].toString() == "0") {
          if (map['data'] != null) {
            // ElderCareEntity model = ElderCareEntity.fromJson(map['data']);
            // setState(() {
            //   dataList = model.rows;
            // });
          } else {
            Toast.show(map["msg"]);
          }
        }
      } else {
        Toast.show(r.statusCode.toString());
      }
    }).catchError((e) {
      page.closeProgress();
      print(e.toString());
      Toast.show(getErrorMessage(e));
    });
  }
}
